package cadastro.action;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;

import services.RotaService;

import com.opensymphony.xwork2.ActionSupport;

public class RotaAction extends ActionSupport implements ServletResponseAware{

	private static final long serialVersionUID = 8442613007164826722L;

	private HttpServletResponse servletResponse;
	
	private String placeMarkers;
	
	private List<Integer> listCaminhoes;
	
	private RotaService rotasService = new RotaService();
	
	public void setServletResponse(HttpServletResponse resp) {
		servletResponse = resp;
	}

	public void printMarkers(){
		System.out.println(placeMarkers);
	}

	/**
	 * @return the placeMarkers
	 */
	public String getPlaceMarkers() {
		return placeMarkers;
	}

	/**
	 * @param placeMarkers the placeMarkers to set
	 */
	public void setPlaceMarkers(String placeMarkers) {
		this.placeMarkers = placeMarkers;
	}
	
	
	
	/**
	 * @return the listCaminhoes
	 */
	public List<Integer> getListCaminhoes() {
		return listCaminhoes;
	}

	/**
	 * @param listCaminhoes the listCaminhoes to set
	 */
	public void setListCaminhoes(List<Integer> listCaminhoes) {
		this.listCaminhoes = listCaminhoes;
	}

	public void cadastrarRota() throws Exception{
	
		rotasService.cadastrarRota(placeMarkers);
		
		//return "SUCCESS";
	}
	
	
	public String buscaCaminhoes(){
		setListCaminhoes(rotasService.buscaCaminhoes());
		System.out.println(getListCaminhoes());
		return SUCCESS;
	}
	
	
}
